package com.qf.fc.dao;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.qf.fc.dto.CommentDto;
import com.qf.fc.entity.Comment;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * 评论表(Comment)表数据库访问层
 *
 * @author makejava
 * @since 2024-09-23 23:34:44
 */
public interface CommentDao extends BaseMapper<Comment> {

    @Select("select c.*,ud.nickname,ud.imageurl,cl.likes from t_comment c inner join t_user_detail ud on c.uid=ud.uid left join (select cid,count(*) likes from t_comment_like group by cid) cl on c.id=cl.cid where c.mid=#{mid} order by c.create_time desc limit #{start},#{size}")
    List<CommentDto> selectLimit(@Param("mid") Integer mid,@Param("start") Integer start,@Param("size") Integer size);

    @Select("select count(*) from t_comment where mid=#{mid}")
    Long selectCount(Integer mid);

}

